package data_structure;

public class leetcode_0206 {
    public ListNode reverseList(ListNode head) {
        if(head==null||head.next==null) return head;
        ListNode q=head;
        ListNode p=head.next;
        ListNode r=head.next.next;
        q.next=null;
        while(true){
            p.next=q;
            if(r==null) return p;
            q=p;
            p=r;
            r=r.next;

        }
    }
}
